{% extends "base.html" %}
{% load i18n bootstrap3 dv_filters %}
{% block head_title %}{{ season.desc }}{% endblock %}

{% block bootstrap3_extra_head %}{{ form.media.css }}{% endblock %}
{% block bootstrap3_extra_script %}{{ form.media.js }}{% endblock %}

{% block container-class %}container-fluid{% endblock %}

{% block content %}
    {% include "challenge/season_header.html" with season=season only %}
    <h4>{% trans "Planning" %}</h4>
        <div class="table-avail-wrapper">
          <table class="table text-center table-avail">
            {% include "challenge/season_availability_thead.html" with sessions=sessions season=season user=request.user preamble_columns=3 chosen_stats=True wishfield=True user_can_see_season=user_can_see_season only %}
            <tbody>
                {% for helper_category,helpers in potential_helpers %}
                    {% if helpers %}
                        <tr><th colspan="{{ sessions.count|add:"5" }}">{{ helper_category }}</th></tr>
                        {% for helper in helpers %}
                        <tr>
                            {% include "challenge/season_availability_partial_helper_columns.html" with helper=helper availabilities=availabilities with_link=season.manager_can_crud %}
                            {{ availabilities|useravailsessions_readonly:helper }}
                        </tr>
                        {% endfor %}
                        {% if helpers.count > 10 %}
                            {% include "challenge/season_availability_partial_head.html" with sessions=sessions season=season preamble_columns=5 user=request.user only %}
                        {% endif %}
                    {% endif %}
                {% endfor %}
            </tbody>
          </table>
        </div>


<div class="hidden-print">
    <a class="btn btn-default" href="{% url 'season-detail' season.pk %}">{% trans "Retour au mois" %}</a>

    <div class="btn-group" role="group" aria-label="exports">
        {% include 'export_buttons.html' with exporturl='season-planning-export' exportargs=season.pk filter_querystring=filter_querystring only %}
    </div>
    {% if season.manager_can_crud %}
        <form method="POST" action="" class="form-inline"  style="display: inline;" novalidate>
            {% csrf_token %}
            {% bootstrap_form form %}
        {% buttons %}
            {% if season.availability_reminder_sent_at %}
                <small class="text-muted pull-right" style="margin-left: 8px; padding-top: 6px;">
                  {% blocktrans %}Rappel envoyé le {% endblocktrans %}{{ season.availability_reminder_sent_at|date }}
                </small>
            {% endif %}
            <a class="btn btn-default pull-right" style="margin-right: 8px;" href="{% url 'season-availability-reminder' season.pk %}">
                {% if season.availability_reminder_sent_at %}{% trans "Renvoyer un  rappel" %}{% else %}{% trans "Envoyer un rappel" %}{% endif %}
            </a>
            <button type="submit" class="btn btn-primary pull-right" style="margin-right: 8px;">{% trans "Disponibilités" %}</button>
            {% endbuttons %}
        </form>

        <a class="pull-right btn btn-primary" href="{% url 'season-staff-update' season.pk %}">{% trans "Attribuer les moniteur·trice·s" %}</a>
    {% endif %}
</div>
{% endblock %}
